package juc.base;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MainRun {
    public static void main(String[] args) throws InterruptedException {
        final int thread_size = 1000;
        ThreadUnSafeExample threadUnSafeExample = new ThreadUnSafeExample();
        CountDownLatch countDownLatch = new CountDownLatch(thread_size);
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < thread_size; i++) {
            executorService.execute(() ->{
                threadUnSafeExample.add();
                countDownLatch.countDown();
            });
        }
        countDownLatch.await();
        executorService.shutdown();
        System.out.println(threadUnSafeExample.get());
        Thread thread = new Thread(() ->{
            System.out.println("woshiyigexiancegn ");
        });
        thread.start();
    }
}
